<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla controller library
jimport('joomla.application.component.controller');

/**
 * FAQ Book Component Controller
 */
class ManagerControllerManager extends JController {

    var $Itemid = "";

    function __construct() {
        parent::__construct();
       
        $this->Itemid = JRequest::getVar('Itemid');
    }

    public function display() {
        parent::display();
    }

    public function savequiz() {

        $mainframe = JFactory::getApplication();
        $row = & JTable::getInstance('UserHive', 'Table');
        $row->user_id = 1;
        $app1 = $_POST['application_area_id1'];
        $app2 = $_POST['application_area_id2'];
        $row->application_area_id = '';
        $row->product_family_id = '';
        $row->sbe_0 = '';
        if (!empty($app1)) {
            $ap1 = explode("|", $app1);
            $row->application_area_id.=$ap1[0];
            $row->product_family_id.=$ap1[1];
            $row->sbe_0.=$ap1[2];
        }

        if (!empty($app2)) {
            $ap2 = explode("|", $app2);

            if (($row->application_area_id) && ($ap2[0])) {
                $row->application_area_id.='^' . $ap2[0];
            } elseif (empty($row->application_area_id) && ($ap2[0])) {
                $row->application_area_id.=$ap2[0];
            }

            if (($row->product_family_id) && ($ap2[1])) {
                $row->product_family_id.='^' . $ap2[1];
            } elseif (empty($row->product_family_id) && ($ap2[1])) {
                $row->product_family_id.=$ap2[1];
            }

            if (($row->sbe_0) && ($ap2[2])) {
                $row->sbe_0.='^' . $ap2[2];
            } elseif (empty($row->sbe_0) && ($ap2[2])) {
                $row->sbe_0.=$ap2[2];
            }
        }

        $row->save($_POST);
        exit;
    }

    
    public function thanks() {
        $this->view = & $this->getView('tourdetail', 'html');
        $this->view->thanks();
    }

    public function contact() {
        $this->view = & $this->getView('tourdetail', 'html');
        $this->view->contact();
    }

    public function social() {
        $this->view = & $this->getView('newticker', 'html');
        $this->view->social();
    }

    public function sendemail() {
        $mailer = & JFactory::getMailer();

        $sender = array($_POST['email'], $_POST['full_name']);
        $mailer->setSender($sender);
        $recipient = array('thanhtungnguyenphp@gmail.com');
        $mailer->addRecipient($recipient);
        $body = $_POST['mess'];
        $mailer->isHTML(true);
        $mailer->Encoding = 'base64';
        $mailer->setBody($body);
        $send = & $mailer->Send();
        if ($send !== true) {
            //echo 'Error sending email: sss ' ;
        } else {
            //echo 'Mail sent';
        }

        $this->view = & $this->getView('tourdetail', 'html');
        $this->view->sendemail();
    }

    

}